const { SendStatusType } = require("../types/index")
const { success } = SendStatusType

function sendResult(res, result, status = success, message = '接口访问成功') {
    res.status(200).send({
        status,
        message,
        result
    }
    )
    return
}

const fs = require('fs').promises;
const path = require('path');

async function delImage(res, paths) {
    let filePath = path.join(__dirname, paths)

    console.log(filePath);
    try {
        await fs.access(filePath)
        await fs.unlink(filePath);
    } catch (err) {
        res.status(500).send(err)
    }
}
module.exports = {
    sendResult,
    delImage
}